package com.egg.ylt.widget;

import android.content.Context;
import android.util.AttributeSet;
import android.widget.ScrollView;

/**
 * Created By Dlx
 * on 2018/12/5 0005
 */
public class ViewStubScrollView extends ScrollView {
    public OnScrollChangedListener onScrollChangeListener;

    public ViewStubScrollView(Context context) {
        super(context);
    }

    public ViewStubScrollView(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    public ViewStubScrollView(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }

    @Override
    protected void onScrollChanged(int l, int t, int oldl, int oldt) {
        super.onScrollChanged(l, t, oldl, oldt);
        if (onScrollChangeListener != null)
        {
            onScrollChangeListener.onScrollChange(this, l, t, oldl, oldt);
        }
        {
            onScrollChangeListener.onScrollBottomListener();
        }
//        if (t == 0 || t + getHeight() > contentView.getHeight() && onScrollChangeListener != null)
//        {
//            onScrollChangeListener.onScrollTopListener();
//        }
    }
    public interface OnScrollChangedListener{
        void onScrollChange(ViewStubScrollView view, int x, int y, int oldx, int oldy);

        void onScrollBottomListener();

        void onScrollTopListener();
    }
}
